package com.ymk.cmd;

import com.ymk.base.cmd.ACmd;
import com.ymk.base.cmd.CmdSign;
import com.ymk.base.utlis.ParamsBuilder;
import com.ymk.bo.work.WorkApplyBO;
import com.ymk.core.code.cmd.WorkApplyCmdCode;
import com.ymk.service.IWorkApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
public class WorkApplyGetCmd extends ACmd {

    @Override
    public CmdSign executeMop(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        WorkApplyBO reqData = super.getData(sign, WorkApplyBO.class);

        ParamsBuilder paramsBuilder = ParamsBuilder.newBuild()
            .addParam("id", reqData.getId())
            .setReturnStruct(sign.getReturnStruct());
        WorkApplyBO respData = this.WorkApplyService.get(paramsBuilder.build());
        respSign.setSource(super.getSource(respData));

        return respSign;
    }

    @Override
    public String getCmdCode() {
        return WorkApplyCmdCode.WORK_APPLY_GET;
    }

    @Override
    public boolean anon(CmdSign sign) {
        return true;
    }
    @Autowired
    private IWorkApplyService WorkApplyService;
}